.TH std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_day_last) 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_day_last) \- std::chrono::operator+,std::chrono::operator-(std::chrono::year_month_day_last)

.SH Synopsis
   Defined in header <chrono>
   constexpr std::chrono::year_month_day_last

       operator+( const std::chrono::year_month_day_last& ymdl,           \fI(since C++20)\fP

                  const std::chrono::months& dm ) noexcept;
   constexpr std::chrono::year_month_day_last

       operator+( const std::chrono::months& dm,                          \fI(since C++20)\fP

                  const std::chrono::year_month_day_last& ymdl )
   noexcept;
   constexpr std::chrono::year_month_day_last

       operator+( const std::chrono::year_month_day_last& ymdl,           \fI(since C++20)\fP

                  const std::chrono::years& dy ) noexcept;
   constexpr std::chrono::year_month_day_last

       operator+( const std::chrono::years& dy,                           \fI(since C++20)\fP

                  const std::chrono::year_month_day_last& ymdl )
   noexcept;
   constexpr std::chrono::year_month_day_last

       operator-( const std::chrono::year_month_day_last& ymdl,           \fI(since C++20)\fP

                  const std::chrono::months& dm ) noexcept;
   constexpr std::chrono::year_month_day_last

       operator-( const std::chrono::year_month_day_last& ymdl,           \fI(since C++20)\fP

                  const std::chrono::years& dy ) noexcept;

   1,2) Adds dm.count() months to the date represented by ymdl. The result has the same
   year() and month() as std::chrono::year_month(ymdl.year(), ymdl.month()) + dm.
   3,4) Adds dy.count() years to the date represented by ymdl. The result is equivalent
   to std::chrono::year_month_day_last(ymdl.year() + dy, ymdl.month_day_last()).
   5) Subtracts dm.count() months from the date represented by ymdl. Equivalent to ymdl
   + -dm.
   6) Subtracts dy.count() years from the date represented by ymdl. Equivalent to ymdl
   + -dy.

   For durations that are convertible to both std::chrono::years and
   std::chrono::months, the years overloads (3,4,6) are preferred if the call would
   otherwise be ambiguous.

.SH Example


// Run this code

 #include <cassert>
 #include <chrono>
 #include <iostream>

 int main()
 {
     auto ymdl{11/std::chrono::last/2020};
     std::cout << ymdl << '\\n';

     ymdl = std::chrono::years(10) + ymdl;
     std::cout << ymdl << '\\n';
     assert(ymdl == std::chrono::day(30)/
                    std::chrono::November/
                    std::chrono::year(2030));

     ymdl = ymdl - std::chrono::months(6);
     std::cout << ymdl << '\\n';
     assert(ymdl == std::chrono::day(31)/
                    std::chrono::May/
                    std::chrono::year(2030));
 }

.SH Output:

 2020/Nov/last
 2030/Nov/last
 2030/May/last
